package main

import "fmt"

/*
Animal 接口实现多态
*/
type Animal interface {
	sleep()
	eat()
	run()
}

type Dog struct {
	name string
}

func (d *Dog) sleep() {
	fmt.Println(d.name + " is sleep...")
}

func (d *Dog) eat() {
	fmt.Println(d.name + " is eat...")
}

func (d *Dog) run() {
	fmt.Println(d.name + " is run...")
}

type Cat struct {
	name string
}

func (c *Cat) sleep() {
	fmt.Println(c.name + " is sleep...")
}

func (c *Cat) eat() {
	fmt.Println(c.name + " is eat...")
}

func (c *Cat) run() {
	fmt.Println(c.name + " is run...")
}

func showAnimal(a Animal) {
	a.sleep()
	a.eat()
	a.run()
}

func main() {
	dog := Dog{name: "jack"}
	showAnimal(&dog)

	cat := Cat{name: "tomm"}
	showAnimal(&cat)
}
